/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 投票活动中心数据
	/// module : structs
	/// </summary>
	public class CenterVoteDataPOD : IPOD 
    {
        public readonly static Func<CenterVoteDataPOD> FACTORY = () => new CenterVoteDataPOD();
		public static Func<CenterVoteDataPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 所有投票记录
        /// </summary>
        private Dictionary<int, int> m_votes;
		
		
        public Dictionary<int, int> votes
        {
            get
            {
                if(m_votes == null)
                {
                    m_votes = new();
                }
                return m_votes;
            }
            private set => m_votes = value;
        }
        public Dictionary<int, int> unsafe_votes
        {
        	get => m_votes;
        	set => m_votes = value;
        }
		
		/*-- constructors --*/
		public CenterVoteDataPOD() {}
		public CenterVoteDataPOD(Dictionary<int, int> votes) {
			this.m_votes = votes;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_map_int_int(m_votes);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            m_votes = _in.Read_map_int_int();
        }
		
		public CenterVoteDataPOD Clone() {
            CenterVoteDataPOD o = DynamicFactory();
            if (m_votes != null) {
                o.m_votes = new (m_votes);
            }
            return o;
        }
        
        public void Clear() {
            m_votes = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "CenterVoteDataPOD [";
			str += "votes=";
			str += m_votes.ToString<int, int>();
			str += "]";
			return str;
		}
		
	}
}